package com.youzan.cloud.component.biz.member.mq;

import com.youzan.cloud.mq.Message;
import com.youzan.cloud.mq.Producer;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;

/**
 * @author tangsen233
 * @version 1.0
 * @description: 会员后置事件 消息者需要业务方实现 (参考)
 * @date 2021/9/23 16:05
 */
@Component
public class ProducerMemberCreateAfter {

    @Resource
    private Producer producer;

    public void send(String topic, String messageKey, String body){
        // topic -> diy创建的topic
        // messageKey -> 业务标识，可以为空
        // body -> 消息体
        producer.send(new Message(topic, messageKey, body.getBytes(StandardCharsets.UTF_8)));
    }
}